/**
 * Description:
 * Class Name:TransientTest
 * Date:2022/5/2 19:50
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第15章_输入输出._15_8_Java9改进的对象序列化._15_8_5_自定义序列化;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class TransientTest {
    public static void main(String[] args) {
        try (
                var oos = new ObjectOutputStream(new FileOutputStream("Chapter_15_8_transient.txt"));
                var ois = new ObjectInputStream(new FileInputStream("Chapter_15_8_transient.txt"))
                ){
            var per = new Person("孙悟空", 500);
            oos.writeObject(per);
            var p = (Person) ois.readObject();
            System.out.println(p.getAge());
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}
